<?php
namespace app\index\controller;
use think\Controller;
class Club extends Controller{
	public function index(){
		$info = model('club')->where('status=1')->select();
		$data = [];
		foreach($info as $v){
			$data[] = $v->toArray();
		}
		$this->assign('data',$data);
		return $this->fetch();
	}
	public function article(){
		if(request()->isPost()){
			//if(session('nickname') != null){
				$da['nickname'] = session('nickname');
				$da['content'] = input('post.content');
				$da['cid'] = input('post.cid');
				model('pin')->data($da)->save();
			// }else{
			// 	$this->error('请先登录');
			// }
		}
			$info = model('pin')->where('cid='.input('get.cid'))->select();
			$data_pin=[];
			foreach($info as $v){
				$data_pin[] = $v->toArray();
			}
			$this->assign('data_pin',$data_pin);
			//$this->assign('data',$data);
		$data = model('club')->where('cid='.input('get.cid'))->find()->toArray();
		$this->assign('data',$data);
		return $this->fetch();
	}
	//租客活动
	public function active(){
		$info = model('club')->where('type="租客活动" && status=1')->select();
		$data = [];
		foreach($info as $v){
			$data[] = $v->toArray();
		}
		$this->assign('data',$data);
		return $this->fetch();
	}
	//品质生活
	public function shenghuo(){
		$info = model('club')->where('type="品质生活" && status=1')->select();
		$data = [];
		foreach($info as $v){
			$data[] = $v->toArray();
		}
		$this->assign('data',$data);
		return $this->fetch();
	}
	//有趣青年
	public function yong(){
		$info = model('club')->where('type="有趣青年" && status=1')->select();
		$data = [];
		foreach($info as $v){
			$data[] = $v->toArray();
		}
		$this->assign('data',$data);
		return $this->fetch();
	}
	//新鲜资讯
	public function zixun(){
		$info = model('club')->where('type="新鲜资讯" && status=1')->select();
		$data = [];
		foreach($info as $v){
			$data[] = $v->toArray();
		}
		$this->assign('data',$data);
		return $this->fetch();
	}
}